/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.os.dao.zakharov.oracle;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Zakharov
 */
@Entity
@Table(name = "REGISTRATION")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Registration.findAll", query = "SELECT r FROM Registration r"),
    @NamedQuery(name = "Registration.findByIdRegistration", query = "SELECT r FROM Registration r WHERE r.idRegistration = :idRegistration"),
    @NamedQuery(name = "Registration.findBySurname", query = "SELECT r FROM Registration r WHERE r.surname = :surname"),
    @NamedQuery(name = "Registration.findByName", query = "SELECT r FROM Registration r WHERE r.name = :name"),
    @NamedQuery(name = "Registration.findByPatronymic", query = "SELECT r FROM Registration r WHERE r.patronymic = :patronymic"),
    @NamedQuery(name = "Registration.findByEmail", query = "SELECT r FROM Registration r WHERE r.email = :email"),
    @NamedQuery(name = "Registration.findByCountry", query = "SELECT r FROM Registration r WHERE r.country = :country"),
    @NamedQuery(name = "Registration.findByCity", query = "SELECT r FROM Registration r WHERE r.city = :city")})
public class Registration implements Serializable {
    private static final long serialVersionUID = 1L;
    
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_REGISTRATION")
    private BigDecimal idRegistration;
    
    @Size(max = 30)
    @Column(name = "SURNAME")
    private String surname;
    
    @Size(max = 30)
    @Column(name = "NAME")
    private String name;
    
    @Size(max = 30)
    @Column(name = "PATRONYMIC")
    private String patronymic;
    
    @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 30)
    @Column(name = "EMAIL")
    private String email;
    
    @Size(max = 30)
    @Column(name = "COUNTRY")
    private String country;
    
    @Size(max = 30)
    @Column(name = "CITY")
    private String city;
    
    @OneToMany(mappedBy = "idRegistration")
    private Collection<Users> usersCollection;

    public Registration() {
    }

    public Registration(BigDecimal idRegistration) {
        this.idRegistration = idRegistration;
    }

    public BigDecimal getIdRegistration() {
        return idRegistration;
    }

    public void setIdRegistration(BigDecimal idRegistration) {
        this.idRegistration = idRegistration;
    }

    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPatronymic() {
        return patronymic;
    }

    public void setPatronymic(String patronymic) {
        this.patronymic = patronymic;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    @XmlTransient
    public Collection<Users> getUsersCollection() {
        return usersCollection;
    }

    public void setUsersCollection(Collection<Users> usersCollection) {
        this.usersCollection = usersCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idRegistration != null ? idRegistration.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Registration)) {
            return false;
        }
        Registration other = (Registration) object;
        if ((this.idRegistration == null && other.idRegistration != null) || (this.idRegistration != null && !this.idRegistration.equals(other.idRegistration))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.os.dao.zakharov.oracle.Registration[ idRegistration=" + idRegistration + " ]";
    }
    
}
